<div ng-controller="frontendUserCtrl">
    <br>
    <!--<p id="errorMsg" class="text-danger" ng-show="showErrorForQueryCondition==true">请选择小区...!</p>-->

    <form class="form-inline" role="form" id="searchTable"
          ng-submit="searchUser(search.selectedCommunity.objId,search.mobilePhone,search.nickName,search.isVUser,search.isTalent,search.userRole)">
        选择小区：
        <!--<select required class="form-control" ng-model="search.selectedCommunity" placeholder="选择小区"-->
                <!--ng-options="community.communityName for community in communityList" ng-change="selectCommunity()">-->
            <!--<option>&#45;&#45;Please Select&#45;&#45;</option>-->
        <!--</select>-->
        <input type = "text" id = "community_select" ng-model="communityId" value = "">

        手机号:
        <input type="text" ng-model="search.mobilePhone" size="8" class="form-control">
        昵称:
        <input type="text" ng-model="search.nickName" size="8" class="form-control">
        V用户：
        <select class="form-control" ng-model="search.isVUser">
            <option></option>
            <option>是</option>
            <option>否</option>
        </select>
        达人：
        <select class="form-control" ng-model="search.isTalent">
            <option></option>
            <option>是</option>
            <option>否</option>
        </select>
        角色：
        <select class="form-control" ng-model="search.userRole">
            <option></option>
            <option>版主</option>
            <option>物业</option>
        </select>
        <br><br>

        注册时间：
        <input type="text" id="startDate" class="form-control datepicker" size="12" data-date-format="yyyy-mm-dd"
               ng-model="search.startDate">
        至：
        <input type="text" id="endDate" class="form-control datepicker" size="12" data-date-format="yyyy-mm-dd"
               ng-model="search.endDate">
        <button type="submit" class="form-control btn btn-secondary">Search</button>
    </form>
    <br>

    <div class="tab-content">
        <paging>
            <ul class="pagination" num-pages="tasks.pageCount" current-page="tasks.currentPage"
                on-select-page="selectPage(page)">
                <li ng-class="{disabled: noPrevious()}"><a ng-click="selectPrevious()">&laquo;</a>

                </li>
                <li ng-repeat="page in pages" ng-class="{active: isActive(page)}"><a
                        ng-click="selectPage(page)">{{page}}</a>

                </li>
                <li ng-class="{disabled: noNext()}"><a ng-click="selectNext()">&raquo;</a>

                </li>
                <li ng-show="currentPage>6"><a ng-click="selectPage(1)">首页</a>

                </li>
            </ul>
        </paging>
        <table class="table table-condensed" width="647">
            <thead>
            <tr>
                <th>用户Id</th>
                <th>手机号码</th>
                <th>来源</th>
                <th>昵称</th>
                <th>性别</th>
                <th>小区</th>
                <th>详细地址</th>
                <th>达人描述</th>
                <th>V用户</th>
                <th>达人</th>
                <th>角色</th>
                <th>黑名单</th>
                <th>创建日期</th>
                <th>备注</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="user in userList.items">
                <td>{{user.objId}}</td>
                <td>{{user.mobilePhone}}</td>
                <td>{{user.source}}</td>
                <td>{{user.nickName}}</td>
                <td>{{user.gender}}</td>
                <td>{{user.community.communityName}}</td>
                <td>{{user.apartmentDetail}}</td>
                <td>{{user.speciality}}<span ng-show="user.userType=='talent'&& !user.speciality">无描述</span></td>
                <td ng-show="user.authenticationStatus==true">是</td>
                <td ng-show="user.authenticationStatus==false">否</td>
                <td ng-show="user.userType=='talent'">是</td>
                <td ng-show="user.userType!='talent'">否</td>
                <td ng-show="user.userRole[0]==1">版主</td>
                <td ng-show="user.userRole[0]==2">物业</td>
                <td ng-show="user.userRole[0]==null">  </td>
                <td ng-show="user.frozenOrNot==true">是</td>
                <td ng-show="user.frozenOrNot==false">否</td>
                <td>{{user.dateCreated | date : 'yyyy-MM-dd'}}</td>
                <td>{{user.remark}}</td>
                <td>
                    <a class="btn btn-warning btn-xs" ng-show="user.frozenOrNot==false"
                       ng-click="blackListConfig(user,0)">拉黑</a>
                    <a class="btn btn-danger btn-xs" ng-show="user.frozenOrNot==true"
                       ng-click="blackListConfig(user,1)">拉白</a>
                    <a class="btn btn-primary btn-xs" ng-click="goDetail(user)">详细信息</a>
                    <!--a class="btn btn-success btn-xs" ng-show="user.authenticationStatus==false&&user.frozenOrNot==false" ng-click="setOrCancelVUser(user,'把该用户设置为V用户吗？',true)">升级V</a-->
                    <a class="btn btn-success btn-xs"
                       ng-show="user.authenticationStatus==false&&user.frozenOrNot==false"
                       ng-click="validateVUserDetails(user,'把该用户设置为V用户吗？',true)">升级V</a>
                    <a class="btn btn-danger btn-xs"
                       ng-show="user.authenticationStatus==true&&user.userType!='talent'&&user.frozenOrNot==false"
                       ng-click="setOrCancelVUser(user,'把该用户取消V用户吗？',false)">取消V</a>
                    <a class="btn btn-info btn-xs"
                       ng-show="user.authenticationStatus==true&&user.userType!='talent'&&user.frozenOrNot==false"
                       ng-click="setOrCancelTalent(user,'把该用户升级为达人吗？','1')">升级达人</a>
                    <a class="btn btn-info btn-xs" ng-show="user.userType=='talent'&&user.frozenOrNot==false"
                       ng-click="setOrCancelTalent(user,'取消该用户的达人资格吗？','0')">取消达人</a>

                    <!--span ng-show="!user.gender">缺少性别资料</span-->
                </td>
            </tr>
            <tr>
                <td></td>
                <td colspan="9" align="center"></td>
            </tr>
            </tbody>
        </table>
    </div>


    <div class="modal fade" id="userDetail" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="userDetailTtiel">用户详细信息</h5>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal">

                        <div class="form-group">
                            <div class="text-left col-sm-2">
                                <img src="{{userDetail.images[0].imageURL}}" width="80" height="80"
                                     class="avatar img-circle">
                            </div>
                            <div class="form-group col-sm-6">
                                <div>
                                    <label class="control-label">昵称：{{userDetail.nickName}}</label>
                                </div>
                                <div>
                                    <label class="control-label">手机：{{userDetail.mobilePhone}}</label>
                                </div>
                                <div>
                                    <!--<label class="control-label ">小区：{{userDetail.community.communityName}}</label>-->
                                    <select ng-model="community" ng-options="m.objId as m.communityName for m in communityLabelList">
                                        <!--ng-change="selectCondition(communityId,category,description)">-->
                                        <option value="">-- 请选择 --</option>
                                    </select>
                                </div>
                                <div>
                                    <label class="control-label ">微信/QQ:{{userDetail.wechatId}}</label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">性别:</label>

                            <div class="col-md-2">
                                <label class="radio-inline">
                                    <input type="radio" name="gender" value="男" ng-model="userDetail.gender">男
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="gender" value="女" ng-model="userDetail.gender">女
                                </label>
                            </div>
                            <label class="control-label col-sm-3">出生年月:</label>

                            <div class="col-md-2">
                                <input type="text" id="birthday" data-provide="datepicker"
                                       class="form-control datepicker" data-date-format="yyyy-mm-dd"
                                       ng-model="userDetail.birthDate" required>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">是否达人:</label>

                            <div class="col-md-2">
                                <input class="form-control" type="text" disabled="true" value="是"
                                       ng-show="userDetail.userType=='Talent'">
                                <input class="form-control" type="text" disabled="true" value="否"
                                       ng-show="userDetail.userType!='Talent'">
                            </div>
                            <label class="control-label col-sm-3">是否V用户:</label>

                            <div class="col-md-2">
                                <input class="form-control" type="text" disabled="true" value="是"
                                       ng-show="userDetail.authenticationStatus==true">
                                <input class="form-control" type="text" disabled="true" value="否"
                                       ng-show="userDetail.authenticationStatus==false">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">单元:</label>

                            <div class="col-md-2">
                                <input class="form-control" type="text" ng-model="userDetail.roomUnit">
                            </div>
                            <label class="control-label col-sm-3">房间号:</label>

                            <div class="col-md-2">
                                <input class="form-control" type="text" ng-model="userDetail.roomNumber">
                            </div>
                        </div>
                        <div class="modal-body">
                            <textarea rows="3" required style="width:100%" placeholder="备注信息..." ng-model="userDetail.remark" >
                            </textarea>

                        </div>

                    </form>

                </div>
                <div class="modal-footer">
                    <button id="saveButton1" type="submit" class="btn btn-default" ng-click="saveUserInfo(userDetail)">
                        保存修改
                    </button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
                <br>
                <br>
            </div>
        </div>
    </div>

    <div class="modal fade" id="validateVUserDetails" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="validateVUserDetails_title">V用户升级资料验证</h5>
                </div>
                <div class="modal-body">
                    <form id="validateVUserDetails_form" class="form-horizontal">

                        <div class="form-group">
                            <div class="text-left col-sm-2">
                                <img src="{{userDetail.images[0].imageURL}}" width="110" height="80"
                                     class="avatar img-circle">
                            </div>
                            <div class="form-group col-sm-3">
                                <div>
                                    <label class="control-label">昵称：{{userDetail.nickName}}</label>
                                </div>
                                <div>
                                    <label class="control-label">手机：{{userDetail.mobilePhone}}</label>
                                </div>
                                <div>
                                    <label class="control-label ">小区：{{userDetail.community.communityName}}</label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">昵称:</label>

                            <div class="col-md-2">
                                <input class="form-control" type="text" disabled="true" ng-model="userDetail.nickName">
                            </div>

                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">微信:</label>

                            <div class="col-md-3">
                                <input class="form-control" type="text" disabled="true" value="{{userDetail.wechatId}}">
                            </div>
                            <label class="control-label col-sm-2">电子邮件:</label>

                            <div class="col-md-3">
                                <input class="form-control" type="text" value="{{userDetail.email}}" disabled="true">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">性别:</label>

                            <div class="col-md-2">
                                <label class="radio-inline">
                                    <input type="radio" name="validateVUserDetails_gender" disabled="true"
                                           id="validateVUserDetails_gender_male" value="男">男
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="validateVUserDetails_gender" disabled="true"
                                           id="validateVUserDetails_gender_female" value="女">女
                                </label>
                                <label for="validateVUserDetails_gender" class="error"></label>
                            </div>
                            <label class="control-label col-sm-3">出生年月:</label>

                            <div class="col-md-2">
                                <input class="form-control" type="text" disabled="true"
                                       value="{{userDetail.birthDate}}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-sm-2">是否达人:</label>

                            <div class="col-md-2">
                                <input class="form-control" type="text" disabled="true" value="是"
                                       ng-show="userDetail.userType=='Talent'">
                                <input class="form-control" type="text" disabled="true" value="否"
                                       ng-show="userDetail.userType!='Talent'">
                            </div>
                            <label class="control-label col-sm-3">是否V用户:</label>

                            <div class="col-md-2">
                                <input class="form-control" type="text" disabled="true" value="是"
                                       ng-show="userDetail.authenticationStatus==true">
                                <input class="form-control" type="text" disabled="true" value="否"
                                       ng-show="userDetail.authenticationStatus==false">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-2">单元:</label>

                            <div class="col-md-2">
                                <input id="validateVUserDetails_roomUnit" class="form-control"
                                       name="validateVUserDetails_roomUnit" type="text" ng-model="userDetail.roomUnit"
                                       value="{{userDetail.roomUnit}}" 　>
                            </div>
                            <label class="control-label col-sm-3">房间号:</label>

                            <div class="col-md-2">
                                <input id="validateVUserDetails_roomNumber" class="form-control"
                                       name="validateVUserDetails_roomNumber" type="text"
                                       ng-model="userDetail.roomNumber" value="{{userDetail.roomNumber}}">
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button id="saveButton2" type="submit" class="btn btn-default" ng-click="">升级</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>

                    </form>

                </div>

                <br>
                <br>
            </div>
        </div>
    </div>

    <div class="modal fade" id="user_modal" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h5 class="modal-title" id="myModalLabel">{{popupTitle}}</h5>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" name="backendUserForm">
                        <div class="form-group">
                            <label for="nickName" id="nickName" class="control-label col-xs-2">用户昵称:</label>

                            <div class="col-xs-3">
                                <input type="text" class="form-control" ng-model="toBeBlackListUserNickName"
                                       id="userName" required placeholder="nickName">
                            </div>
                        </div>

                        <div class="form-group" id="reasonInput">
                            <label class="control-label  col-xs-2" for="reason">拉黑原因:</label>

                            <div class="col-xs-6">
                                <textarea rows="6" class="form-control" ng-model="toBeBlackListUserReason"
                                          required></textarea>
                            </div>
                        </div>

                        <div class="modal-footer">
                            <button id="saveButton" type="submit" class="btn btn-default"
                                    ng-click="saveBlackListOrWhiteList(toBeBlackListUserObjId,toBeBlackListUserFrozen,toBeBlackListUserReason)">
                                Save
                            </button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script>


    Date.prototype.format = function (format) {
        var o = {
            "M+": this.getMonth() + 1, //month
            "d+": this.getDate(), //day
            "h+": this.getHours(), //hour
            "m+": this.getMinutes(), //minute
            "s+": this.getSeconds(), //second
            "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
            "S": this.getMilliseconds() //millisecond
        }
        if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
                (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o) if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1,
                    RegExp.$1.length == 1 ? o[k] :
                            ("00" + o[k]).substr(("" + o[k]).length));
        return format;
    }

    var fromDate = $('#startDate').datepicker().on('changeDate', function (ev) {
        //alert(ev.date.format('yyyy-MM-dd'));
        //$scope.startDate=ev.date.format('yyyy-MM-dd');
        $("#startDate").val(ev.date.format('yyyy-MM-dd'));
    });

    var toDate = $('#endDate').datepicker().on('changeDate', function (ev) {
        // alert(ev.date.format('yyyy-MM-dd'));
        //$scope.endDate=ev.date.format('yyyy-MM-dd');
        $("#endDate").val(ev.date.format('yyyy-MM-dd'));
    });

</script>
